import 'package:flutter/material.dart';

class StackAlignPage extends StatelessWidget {
  const StackAlignPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size; // 获取屏幕信息

    return ListView(
      children: [
        SizedBox(
          height: size.height - 56,
          child: Stack(
            children: [
              ListView(
                children: (() {
                  List<Widget> list = [];
                  for (var i = 0; i < 20; i++) {
                    list.add(Container(
                      height: 44,
                      color: Colors.amber,
                      child: Text(
                        'list-$i',
                      ),
                    ));
                    list.add(const Divider());
                  }
                  return list;
                })(),
              ),
              Container(
                width: double.infinity,
                color: Colors.cyan,
                child: const Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [Text('菜单1'), Text('菜单1-right')],
                ),
              ),
              Positioned(
                left: 0,
                bottom: 20,
                child: Container(
                  width: size.width,
                  color: Colors.cyan,
                  child: const Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [Text('菜单2'), Text('菜单2-right')],
                  ),
                ),
              ),
              Align(
                // Alignment.centerRight = Alignment(1.0, 0.0)
                alignment: Alignment.centerRight,
                child: Container(
                  width: 200,
                  color: Colors.cyan,
                  child: const Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [Text('菜单3'), Text('菜单3-right')],
                  ),
                ),
              ),
            ],
          ),
        ),
      ],
    );
  }
}
